package com.ruihu.admin.module.business.task.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruihu.admin.module.business.task.domain.dto.TaskNodeInstDTO;
import com.ruihu.admin.module.business.task.domain.entity.TaskNodeInstEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 *  [ 任务环节实例表 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c) 瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date  2022-08-30 17:01:07
 * @since JDK1.8
 */
@Data
public class TaskNodeInstVO {
    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("任务环节ID")
    private Long taskNodeId;

    @ApiModelProperty("任务环节名称")
    private String taskNodeName;

    @ApiModelProperty("节点序号")
    private Integer sortNo;

    @ApiModelProperty("主任务ID")
    private Long mainTaskId;

    @ApiModelProperty("操作")
    private String action;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    public static TaskNodeInstVO convertToTaskNodeInstVO(TaskNodeInstEntity taskNodeInstEntity) {
        if (taskNodeInstEntity == null) {
            return null;
        }

        TaskNodeInstVO taskNodeInstVO = new TaskNodeInstVO();
        taskNodeInstVO.setTaskNodeId(taskNodeInstEntity.getTaskNodeId());
        taskNodeInstVO.setTaskNodeName(taskNodeInstEntity.getTaskNodeName());
        taskNodeInstVO.setSortNo(taskNodeInstEntity.getSortNo());
        taskNodeInstVO.setMainTaskId(taskNodeInstEntity.getMainTaskId());
        taskNodeInstVO.setId(taskNodeInstEntity.getId());
        taskNodeInstVO.setUpdateTime(taskNodeInstEntity.getUpdateTime());
        taskNodeInstVO.setCreateTime(taskNodeInstEntity.getCreateTime());

        return taskNodeInstVO;
    }

    public static TaskNodeInstVO convertToTaskNodeInstVO(TaskNodeInstDTO taskNodeInstDTO) {
        if (taskNodeInstDTO == null) {
            return null;
        }
        TaskNodeInstVO taskNodeInstVO = new TaskNodeInstVO();
        taskNodeInstVO.setId(taskNodeInstDTO.getId());
        taskNodeInstVO.setTaskNodeId(taskNodeInstDTO.getTaskNodeId());
        taskNodeInstVO.setTaskNodeName(taskNodeInstDTO.getTaskNodeName());
        taskNodeInstVO.setSortNo(taskNodeInstDTO.getSortNo());
        taskNodeInstVO.setMainTaskId(taskNodeInstDTO.getMainTaskId());
        taskNodeInstVO.setAction(taskNodeInstDTO.getAction());
        taskNodeInstVO.setCreateTime(taskNodeInstDTO.getCreateTime());
        taskNodeInstVO.setUpdateTime(taskNodeInstDTO.getUpdateTime());

        return taskNodeInstVO;
    }
}
